package com.kx.center.controller;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baidu.ueditor.ActionEnter;

/**
 * @description UEditor 富文本编辑器 统一提交接口路径
 * @version 1.0
 * @author Scott
 * @date 2016年1月10日 下午5:07:46
 */
@Controller
@RequestMapping("ueditor")
public class UeditorController {

	@SuppressWarnings("deprecation")
	@RequestMapping(value = "uploadFile", produces = "application/json;charset=UTF-8")
	@ResponseBody
	public String uploadFile(HttpServletRequest request ,HttpServletResponse response) {
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		response.setHeader("Content-Type", "text/html");
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setHeader("Access-Control-Allow-Headers", "X-Requested-With,X_Requested_With");

		String rootPath = request.getRealPath("/");

		return new ActionEnter(request, rootPath).exec();
	}

}
